home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / moni / systemviewer.lha / SysCommon.c < prev    next >
C/C++ Source or Header  |  2001-02-16  |  3KB  |  154 lines

  1. /****h* AmigaTalk/SysCommon.c *************************************
  2. * NAME
  3. *    SysCommon.c 
  4. *
  5. * HISTORY
  6. *    05/02/99 - Deleted code & variables associated with
  7. *               RenderHook(), since it's no longer necessary 
  8. *               for the latest version of the OS to highlight
  9. *               the selected ListView item.
  10. * FUNCTIONAL INTERFACE:
  11. *
  12. *   PUBLIC int  SetupSystemList( (*OpenWindowFunc)( void ) );
  13. *
  14. *   PUBLIC void ShutdownSystemList( void );
  15. *
  16. *******************************************************************
  17. *
  18. */
  19.  
  20. #include <string.h>
  21.  
  22. #include <exec/types.h>
  23. #include <exec/lists.h>
  24. #include <exec/nodes.h>
  25.  
  26. #include <AmigaDOSErrs.h>
  27.  
  28. #include <intuition/intuition.h>
  29. #include <intuition/classes.h>
  30. #include <intuition/classusr.h>
  31. #include <intuition/gadgetclass.h>
  32.  
  33. #include <libraries/gadtools.h>
  34.  
  35. #include <graphics/displayinfo.h>
  36. #include <graphics/gfxbase.h>
  37. #include <graphics/gfxmacros.h>   // for SetAfPt() macro.
  38.  
  39. #include <clib/exec_protos.h>
  40. #include <clib/intuition_protos.h>
  41. #include <clib/gadtools_protos.h>
  42. #include <clib/graphics_protos.h>
  43. #include <clib/diskfont_protos.h>
  44.  
  45. #include <pragmas/exec_pragmas.h>
  46. #include <pragmas/intuition_pragmas.h>
  47. #include <pragmas/gadtools_pragmas.h>
  48. #include <pragmas/graphics_pragmas.h>
  49.  
  50. #include "CPGM:GlobalObjects/CommonFuncs.h"
  51.  
  52. #define   ALLOCATE_VARS 1
  53.  
  54. # include "SysLists.h"
  55.  
  56. #undef    ALLOCATE_VARS
  57.  
  58. PRIVATE struct Library  *UtilityBase;
  59. PRIVATE struct DrawInfo *drawInfo = NULL;
  60.  
  61. PRIVATE int SetupScreen( void )
  62. {
  63.    Font = &Attr;
  64.     
  65.    if ((Scr = LockPubScreen( PubScreenName )) == NULL)
  66.       return( -1 );
  67.  
  68.    /* this statement was NOT generated by GadToolsBox: */ 
  69.    if ((drawInfo = GetScreenDrawInfo( Scr )) == NULL)
  70.       {
  71.       UnlockPubScreen( NULL, Scr );
  72.       return( -2 );
  73.       }
  74.  
  75.    ComputeFont( Scr, Font, &CFont, 0, 0 );
  76.  
  77.    if ((VisualInfo = GetVisualInfo( Scr, TAG_DONE )) == NULL)
  78.       {
  79.       /* this statement was NOT generated by GadToolsBox: */ 
  80.       FreeScreenDrawInfo( Scr, drawInfo );
  81.       UnlockPubScreen( NULL, Scr );
  82.       return( -3 );
  83.       }
  84.  
  85.    return( 0L );
  86. }
  87.  
  88. PRIVATE void CloseDownScreen( void )
  89. {
  90.    if (VisualInfo != NULL)
  91.       {
  92.       FreeVisualInfo( VisualInfo );
  93.       VisualInfo = NULL;
  94.       }
  95.  
  96.    /* this statement was NOT generated by GadToolsBox: */ 
  97.    if (drawInfo != NULL)
  98.       {
  99.       FreeScreenDrawInfo( Scr, drawInfo );
  100.       drawInfo = NULL;
  101.       } 
  102.  
  103.    if (Scr != NULL)
  104.       {
  105.       UnlockPubScreen( NULL, Scr );
  106.       Scr = NULL;
  107.       }
  108.  
  109.    return;
  110. }
  111.  
  112. PUBLIC int SetupSystemList( int (*OpenWindowFunc)( void ) )
  113. {
  114.    if (OpenLibs() < 0)
  115.       return( -1 );
  116.       
  117.    if ((UtilityBase = OpenLibrary( "utility.library", 39 )) == NULL)
  118.       {
  119.       CloseLibs();
  120.       return( -2 );
  121.       }
  122.  
  123.    if (SetupScreen() < 0)
  124.       {
  125.       CloseLibs();
  126.       CloseLibrary( (struct Library *) UtilityBase );
  127.       return( -3 );
  128.       }   
  129.  
  130.    if (OpenWindowFunc() < 0)
  131.       {
  132.       CloseDownScreen();
  133.       CloseLibrary( (struct Library *) UtilityBase );
  134.       CloseLibs();
  135.       return( -4 );
  136.       }   
  137.  
  138.    return( 0 );   
  139. }
  140.  
  141. PUBLIC void ShutdownSystemList( void )
  142. {
  143.    // Window has to be closed by the HandleIDCMP() function.
  144.  
  145.    CloseDownScreen();
  146.    CloseLibrary( (struct Library *) UtilityBase );
  147.    CloseLibs();
  148.    return;
  149. }
  150.  
  151. /* -------------------- END of SysCommon.c file! ----------------- */
  152.